﻿using System;
using SS4U.Library.ConfigurationClasses;
using umbraco.interfaces;

namespace SS4U.Section.Configuration
{
    public class Tasks : ITaskReturnUrl
    {
        #region ITaskReturnUrl Members

        public string ReturnUrl { get; private set; }

        #endregion

        #region ITask Members

        public string Alias { get; set; }
        public int ParentID { get; set; }
        public int TypeID { get; set; }
        public int UserId { private get; set; }

        public bool Delete()
        {
            throw new NotImplementedException();
        }


        public bool Save()
        {
            //if (ParentID == -1)
            //{
                
            //}

            Library.Configuration.Root.SearchDefinitions.Add(new SearchDefinition
                                                                 {
                                                                     IsDefault = true,
                                                                     IterationType = IterationType.IterateAll,
                                                                     Name = Alias
                                                                 });

            ReturnUrl = string.Format("plugins/SS4U/EditSearchDefinition.aspx?id={0}", Alias);
            return true;
        }


        #endregion
    }
}